package com.ruoyi.web.controller.ring.app;

import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.ring.domain.RingDevice;
import com.ruoyi.ring.service.IRingDeviceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;

/**
 * 设备 APP
 * 
 * @author liuwp
 * @date 2025-08-18
 */
@Slf4j
@RestController
@RequestMapping("/ring/app/ring_device")
public class AppDeviceController extends BaseController
{
    @Resource
    private IRingDeviceService ringDeviceService;

    /**
     * 绑定设备 APP
     */
    @PostMapping("/add/device")
    public AjaxResult addDevice(@RequestBody RingDevice ringDevice) {
        long userId = SecurityUtils.getUserId();
        log.info("绑定设备addDevice: userId={}, param={}", userId, JSON.toJSONString(ringDevice));
        ringDevice.setUserId(userId);
        return toAjax(ringDeviceService.insertRingDevice(ringDevice));
    }
}
